import { http } from "@/utils/http";
import type { ResultTable } from "@/api/type";
import type { FormItemProps } from "@/views/learn/courses/utils/types";

const modulePath = "/learn/courses";
type result = {
  code: number;
  msg: string;
  data: FormItemProps;
};

/** 课程列表 */
export const getCoursesList = (params?: object) => {
  return http.request<ResultTable>("get", modulePath + "/list", {
    params
  });
};

/** 新增 */
export const coursesAdd = (data?: FormItemProps) => {
  return http.request<result>("post", modulePath + "/add", { data });
};

/** 修改 */
export const coursesUpdate = (data?: FormItemProps) => {
  return http.request<result>("put", modulePath + "/update", {
    data
  });
};

/** 删除 */
export const coursesDel = (data: object) => {
  return http.request<result>("delete", modulePath + "/delete", {
    data
  });
};
